package com.chen.cloudpicture.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chen.cloudpicture.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.chen.cloudpicture.model.dto.picture.*;
import com.chen.cloudpicture.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chen.cloudpicture.model.entity.User;
import com.chen.cloudpicture.model.vo.PictureVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 25480
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-07-26 15:08:27
 */
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    // 快速构建图片查询条件
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    // 单条VO转换
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    // 分页获取多条图片封装
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    // 校验图片
    void validPicture(Picture picture);

    /**
     * 图片审核
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    // 填充审核信息
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量抓取并上传图片
     *
     * @return 返回成功创建的图片数
     */
    Integer uploadPictureByBatch(
            PictureUploadByBatchRequest pictureUploadByBatchRequest,
            User loginUser
    );

    /**
     * 清除对象存储中的图片
     * @param oldPicture
     */
    void clearPictureFile(Picture oldPicture);

    /**
     * 校验空间图片的权限
     */
    void checkPictureAuth(Picture picture, User loginUser);

    // 删除图片
    void deletePicture(long pictureId, User loginUser);

    // 编辑图片
    void editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * 图片颜色相似度查询
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 批量编辑图片
     */
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * 创建 AI 扩图任务
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(
            CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);
}
